module("SplashScene", package.seeall)

function create()
    local visibleSize = cc.Director:getInstance():getVisibleSize()
    local origin = cc.Director:getInstance():getVisibleOrigin()

	local scene = cc.Scene:create()

	local layer = cc.LayerColor:create(cc.c4b(255, 255, 255, 255))

	local logoSprite = cc.Sprite:create("res/logo.jpg")
	logoSprite:setPosition(cc.p(visibleSize.width / 2, visibleSize.height / 2))

	scene:addChild(layer)
	layer:addChild(logoSprite)

	deferredCall(loadGameScene, 0)

	local session = CCIceSession:create()
	local connectInfo = ConnectionInfo:new("127.0.0.1", 1000, "test", "test", 10, "GameSession")

	local function onConnected()
		print("onConnected")
	end

	local function onConnectFailed()
		print("onConnectFailed")
	end

	local function onDisconnected(ex)
		print("onDisconnected")
	end

	session.eventConnected:addScriptHandler(onConnected)
	session.eventConnectFailed:addScriptHandler(onConnectFailed)
	session.eventDisconnected:addScriptHandler(onDisconnected)

	session:connect(connectInfo)

	return scene
end

function loadGameScene()
	require("src.SceneManager")
	require("src.Login.LoginScene")
	require("src.Home.HomeScene")
	require("src.Battle.BattleScene")

	--SceneManager.switchToScene(LoginScene.create())
	SceneManager.switchToScene(BattleScene.create())
end